﻿
using MD5Hash;
using MODEL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class suerdal
    {
        public suerdal(hotest hotest)
        {
            Hotest = hotest;
        }

        public hotest Hotest { get; }
        public int Add(suer suer)
        {
            suer.Pwss = suer.Pwss.GetMD5();
            Hotest.suers.Add(suer);
            return Hotest.SaveChanges();
        }
        public int Deng(string name,string pwd)
        {
            var hang=Hotest.suers.FirstOrDefault(x=>x.Name==name);
            if (hang==null)
            {
                return -1;
            }
            else if(hang.Pwss==pwd.GetMD5())
            {
                return 1;
            }
            return 0;
        }
    }
}
